package com.yidu.best.basicSetup.trusteeset.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yidu.best.basicSetup.exchange.util.IDUtil;
import com.yidu.best.basicSetup.trusteeset.dao.TrusteeDao;
import com.yidu.best.basicSetup.trusteeset.domain.Trustee;
import com.yidu.best.basicSetup.trusteeset.domain.TrusteeVo;
import com.yidu.best.basicSetup.trusteeset.service.TrusteeService;

@Service
public class TrusteeServiceImpl implements TrusteeService {
	
	@Autowired
	private TrusteeDao trusteeDao;
	
	public TrusteeDao getTrusteeDao() {
		return trusteeDao;
	}

	public void setTrusteeDao(TrusteeDao trusteeDao) {
		this.trusteeDao = trusteeDao;
	}
	
	public TrusteeServiceImpl() {
	
	}

	public TrusteeServiceImpl(TrusteeDao trusteeDao) {
		super();
		this.trusteeDao = trusteeDao;
	}

	
	
	
	
	@Override
	public Map<String, Object> findQueryPageTrustee(TrusteeVo trusteeVo) {
		
		int page = (trusteeVo.getPage()-1) *trusteeVo.getLimit().shortValue();
		trusteeVo.setPage(page);
		int count = trusteeDao.findCountTrustee(trusteeVo);
		List<Trustee> trusteeList = trusteeDao.findQueryPageTrustee(trusteeVo);
		System.out.println(count);
		System.out.println(trusteeList);
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("code",0);
		map.put("msg","");
		map.put("count",count);
		map.put("data",trusteeList);
		return map;
	}

	
	/**
	 * 删除
	 */
	@Override
	public int deleteTrustee(String trusteeId) {
		System.out.println(trusteeId);
		return this.trusteeDao.deleteTrustee(trusteeId);
	}
	
	/**
	 * 修改
	 */
	@Override
	public int updateTrustee(Trustee trustee) {
		return trusteeDao.updateTrustee(trustee);
	}
	
	/**
	 * 添加
	 */
	@Override
	public int addTrustee(Trustee trustee) {
		
		trustee.setTrusteeId(IDUtil.getUUID());
		int rs = trusteeDao.addTrustee(trustee);
		
		
		return rs;
	}
	
	/**
	 * 查询所有
	 */
	@Override
	public List<Trustee> findByAllTrustee() {
		
		return trusteeDao.findByAllTrustee();
	}

}
